From 4673f0a6aa896054feab4fc7cc6334a7f7dd64c9 Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Fri, 5 Aug 2016 22:31:19 -0400 Subject: [PATCH] Use `char` when using single character as `Pattern`. --- src/cargo/sources/git/source.rs | 2 +- src/cargo/sources/path.rs | 2 +- src/cargo/sources/registry/index.rs | 2 +- src/cargo/util/config.rs | 4 ++-- src/cargo/util/toml.rs | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/cargo/sources/git/source.rs b/src/cargo/sources/git/source.rs index 20118821c..c2254aa97 100644 --- a/src/cargo/sources/git/source.rs +++ b/src/cargo/sources/git/source.rs @@ -79,7 +79,7 @@ pub fn canonicalize_url(url: &Url) -> Url { let mut url = url.clone(); // Strip a trailing slash - if url.path().ends_with("/") { + if url.path().ends_with('/') { url.path_segments_mut().unwrap().pop_if_empty(); } diff --git a/src/cargo/sources/path.rs b/src/cargo/sources/path.rs index 6ae4cdf1a..052d01c7d 100644 --- a/src/cargo/sources/path.rs +++ b/src/cargo/sources/path.rs @@ -288,7 +288,7 @@ impl<'cfg> PathSource<'cfg> { let dir = try!(dir).path(); let name = dir.file_name().and_then(|s| s.to_str()); // Skip dotfile directories - if name.map(|s| s.starts_with(".")) == Some(true) { + if name.map(|s| s.starts_with('.')) == Some(true) { continue } else if is_root { // Skip cargo artifacts diff --git a/src/cargo/sources/registry/index.rs b/src/cargo/sources/registry/index.rs index 7be0a309c..5f27b4b2a 100644 --- a/src/cargo/sources/registry/index.rs +++ b/src/cargo/sources/registry/index.rs @@ -180,7 +180,7 @@ impl<'cfg> Registry for RegistryIndex<'cfg> { summaries.retain(|s| { match self.source_id.precise() { Some(p) if p.starts_with(dep.name()) && - p[dep.name().len()..].starts_with("=") => { + p[dep.name().len()..].starts_with('=') => { let vers = &p[dep.name().len() + 1..]; s.version().to_string() == vers } diff --git a/src/cargo/util/config.rs b/src/cargo/util/config.rs index 43721f016..df319125d 100644 --- a/src/cargo/util/config.rs +++ b/src/cargo/util/config.rs @@ -197,8 +197,8 @@ impl Config { pub fn get_path(&self, key: &str) -> CargoResult>> { if let Some(val) = try!(self.get_string(&key)) { - let is_path = val.val.contains("/") || - (cfg!(windows) && val.val.contains("\\")); + let is_path = val.val.contains('/') || + (cfg!(windows) && val.val.contains('\\')); let path = if is_path { val.definition.root(self).join(val.val) } else { diff --git a/src/cargo/util/toml.rs b/src/cargo/util/toml.rs index 6fe9e285f..7b805d51b 100644 --- a/src/cargo/util/toml.rs +++ b/src/cargo/util/toml.rs @@ -93,7 +93,7 @@ fn try_add_files(files: &mut Vec, root: PathBuf) { // even valid UTF-8. Here we just ignore all of them and require // that they are explicitly specified in Cargo.toml if desired. f.file_name().and_then(|s| s.to_str()).map(|s| { - !s.starts_with(".") + !s.starts_with('.') }).unwrap_or(true) })) } @@ -925,7 +925,7 @@ impl TomlTarget { Some(ref name) => { if name.trim().is_empty() { Err(human("library target names cannot be empty.".to_string())) - } else if name.contains("-") { + } else if name.contains('-') { Err(human(format!("library target names cannot contain hyphens: {}", name))) } else { -- 2.30.2